﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MMITDomain.Abstract;
using MMITDomain.Entities;

namespace MMITDomain.Concrete
{
    public class EFTransactionChargeRepository : ITransactionChargeRepository
    {
        EFDbContext dbContext = new EFDbContext();

        #region ITransactionChargeRepository Members

        public IQueryable<TransactionCharge> TransactionCharges
        {
            get 
            {
                return dbContext.TrasactionCharges;
            }
        }

        public void SaveTransactionCharge(TransactionCharge objTransactionCharge)
        {
            if (objTransactionCharge.Id == 0)
            {
                dbContext.TrasactionCharges.Add(objTransactionCharge);
            }

            dbContext.SaveChanges();
        }

        public void DeleteTransactionCharge(TransactionCharge objTransactionCharge)
        {
            dbContext.TrasactionCharges.Remove(objTransactionCharge);

            dbContext.SaveChanges();
        }


        public TransactionCharge GetTransactionChargeById(int iTransactionChargeId)
        {
            return dbContext.TrasactionCharges.Find(iTransactionChargeId);
        }

        #endregion
    }
}
